import {PathUtils} from "./PathUtils";

export interface File {
  /**
   * 文件id
   */
  id: string;
  /**
   * 文件唯一md5
   */
  fileInfoId: string;

  /**
   * 文件名称
   */
  fileName: string;
  /**
   * 文件名称
   */
  originalFilename: string;
}

export class FastFileUtils {
  static THUMBN = "__thumbn__";

  static fileToSaveFileName(file) {
    let fileName = PathUtils.getFileNameNoExt(file.originalFilename)
    let ext = PathUtils.extName(file.originalFilename)
    let md5 = file.fileInfoId
    let saveFileName = fileName + '_' + md5 + ext
    return saveFileName
  }

  static fileToSaveFileNameT(file: File) {
    let fileName = PathUtils.getFileNameNoExt(file.originalFilename)
    let ext = PathUtils.extName(file.originalFilename)
    let md5 = file.fileInfoId
    let saveFileName = fileName + "_" + md5 + FastFileUtils.THUMBN + ext
    return saveFileName
  }
}
